package com.hualan.util;

import lombok.Data;

@Data
public class R {
//    操作结果码
    private int code;
//    操作结果描述
    private String msg;
//    前端页面要渲染的数据
    private Object data;

//    操作成功
    public static R success(Object flag){
        R r = new R();
        r.code = 200;
        r.msg = "操作成功";
        r.setData(flag);
        return r;
    }

//    操作失败
    public static R fail(Object flag){
        R r = new R();
        r.code = 500;
        r.msg = "操作失败";
        r.setData(flag);
        return r;
    }
    public static R exp(Object resg){
        R r = new R();
        r.code = 300;
        r.msg = "系统异常";
        r.setData("");
        return r;
    }

}
